473,468 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

href and onclick property of anchor tag.

dmjpro
2,476 Top Contributor
Today i encountered a problem with anchor tag in IE 6.
Basically it is told that ... we should write ..

Expand|Select|Wrap|Line Numbers
  1. <a herf="javascript:void(0);" onclick="function_call(..);return false;">Display Name</a>
Why it is suggested? If inside that function call if i try to change the href value that window then it does not work if i don't have return false statement after function call. If i have that then it works. But if i have return false inside the function then it also does not work. Why does it happen ?
Sep 24 '08 #1
2 14214
Dormilich
8,658 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. onclick="function() {return false;}" --> onclick="false"
  2. onclick="return function() {return false}" --> onclick="return false"
  3. // compare to
  4. onclick="function() {...}; return false;" --> onclick="{some action}; return false;"
these are two different statements

I think it has something to do with the fact that both the event and the hypertext reference fire on click.
Sep 24 '08 #2
dmjpro
2,476 Top Contributor
Expand|Select|Wrap|Line Numbers
  1. onclick="function() {return false;}" --> onclick="false"
  2. onclick="return function() {return false}" --> onclick="return false"
  3. // compare to
  4. onclick="function() {...}; return false;" --> onclick="{some action}; return false;"
these are two different statements

I think it has something to do with the fact that both the event and the hypertext reference fire on click.
Oh Shit!
Sorry i could have explained myself ...shame on me ... :(
Anyway thanks ....
Sep 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Christian Radermacher | last post by:
Hi, the following code has the mentioned behaviour: <html> <head> <script type="text/javascript"> function newA() { for (i=0;i<3;i++) { var a = window.frames.document.createElement("a");
4
by: Johnny | last post by:
I have a page with a button that has the following link: <a href="/somelink?org.apache.struts.taglib.html.TOKEN=ef9f9f5973be37ffe39c60227f402770#" onclick="javascript:go( event, 'myForm');return...
10
by: Bill H | last post by:
I used a bit of JS on a page that is fairly long and didn't like the way that <A HREF='#' ONCLICK=\"... refreshed the page to the top. Removing the HREF (<A ONCLICK=\"...) solved my...
4
by: Jerry Sievers | last post by:
JS Programmers, "I'm a server-side coder PHP, Postgres etc... My question; Given the following anchor <a href="http://www.somesite.com/somefile.html">link text</a> Is there a way to code an...
1
by: james.kingston | last post by:
I've read that one must return false from an onclick handler attached to an anchor if we wanted to prevent the browser from following the href. In a greasemonkey script I'm hacking together with...
6
by: eswanson | last post by:
In jscript, I would like to be able to set the href attribute of the anchor element. I have a aspnet:hyperlink button on the page, but I would like to be able to set the href attribute of this...
13
by: Logos | last post by:
There seems to be a serious difference between how FF an IE handle an anchor with an href containing a # and an onclick event. If the onclick event returns false, IE does not change...
10
by: Edwin Knoppert | last post by:
I have an asp.net imagebutton with a clickevent. I have enclosed an anchor around the image and a small text. If i click the image the event is executed (while the href of the anchor shows in the...
2
by: Peter Laman | last post by:
In my app I need to dynamically generate a series hyperlinks. Each hyperlink's action must be to focus a field in a <form>. I created the following function to create such a link (the argument is a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.